import { WeaForm } from 'comsMobx';
import { observable } from 'mobx';


class MyField extends WeaForm.MyField {
    constructor(props) {
        super(props);
    }
    @observable valueSpan = null;
    @observable valueObj = null;
    @observable editable = false;
    @observable modified = false;
    oldValue: any;

    set: Function;
    validate: Function;
    showErrors: Function;

    @observable browserProps: any = {};

    onChange = (...args) => {
        if (args[1]) this.valueSpan = args[1];
        if (args[2]) this.valueObj = args[2];
        this.set(args[0]);
        this.validate();
        this.showErrors(true);
    }
}
const bindings = {
    default: {
        id: 'id',
        name: 'name',
        editable: 'editable',
        value: 'value',
        valueSpan: 'valueSpan',
        valueObj: 'valueObj',
        label: 'label',
        checked: 'checked',
        placeholder: 'placeholder',
        disabled: 'disabled',
        onChange: 'onChange',
        onBlur: 'onBlur',
        onFocus: 'onFocus',
        autoFocus: 'autoFocus',
        browserProps: 'browserProps',
    }
};
export default class CubeForm extends WeaForm {
    makeField(props) {
        return new MyField(props);
    }

    bindings() {
        return bindings;
    }
}